home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Rectangle;
-
- public class LabelButton extends ButtonBase implements AlignStyle, BevelStyle {
- public static final int INDENT_ZERO = 0;
- public static final int INDENT_ONE = 1;
- public static final int INDENT_TWO = 2;
- protected String sLabelButton;
- protected boolean showLabel;
- private int alignStyle;
- private int bevelStyle;
- private Color color1;
- private Color color2;
- private Color textColor;
- private Color borderedColor;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_0;
- private int xTemp;
- private int yTemp;
- private int indent;
- private boolean bOsFlag;
-
- public LabelButton() {
- this("", 1, 2, Color.black, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3) {
- this(var1, var2, var3, Color.black, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3, Color var4) {
- this(var1, var2, var3, var4, 0, true);
- }
-
- public LabelButton(String var1, int var2, int var3, int var4) {
- this(var1, var2, var3, Color.black, var4, true);
- }
-
- public LabelButton(String var1, int var2, int var3, Color var4, int var5, boolean var6) {
- this.bOsFlag = false;
- String var7 = System.getProperty("os.name");
- if (!var7.startsWith("S") && !var7.startsWith("OSF")) {
- this.bOsFlag = false;
- } else {
- this.bOsFlag = true;
- ((Component)this).setFont(new Font("Dialog", 0, 10));
- }
-
- this.sLabelButton = var1;
- this.textColor = var4;
- this.borderedColor = Color.black;
- this.setBorderIndent(var5);
- this.setAlignStyle(var2);
- this.setBevelStyle(var3);
- super.showFocus = true;
- }
-
- public void setAlignStyle(int var1) {
- this.alignStyle = var1;
- }
-
- public int getAlignStyle() {
- return this.alignStyle;
- }
-
- public void setBevelStyle(int var1) {
- this.bevelStyle = var1;
- switch (var1) {
- case 0:
- this.color1 = Color.black;
- this.color2 = Color.gray;
- return;
- case 1:
- this.color1 = Color.gray;
- this.color2 = Color.black;
- return;
- case 2:
- this.color1 = this.borderedColor;
- this.color2 = this.borderedColor;
- return;
- default:
- this.color1 = this.color2 = null;
- }
- }
-
- public int getBevelStyle() {
- return this.bevelStyle;
- }
-
- public void setBorderIndent(int var1) {
- if (var1 < 0) {
- this.indent = 0;
- } else if (var1 > 2) {
- this.indent = 2;
- } else {
- this.indent = var1;
- }
- }
-
- public int getBorderIndent() {
- return this.indent;
- }
-
- public void setBorderedColor(Color var1) {
- this.borderedColor = var1;
- if (this.bevelStyle == 2) {
- this.color1 = var1;
- this.color2 = var1;
- }
-
- ((Component)this).invalidate();
- }
-
- public void setText(String var1) {
- this.sLabelButton = var1;
- }
-
- public String getText() {
- return this.sLabelButton;
- }
-
- public void setTextColor(Color var1) {
- this.textColor = var1;
- }
-
- public Color getTextColor() {
- return this.textColor;
- }
-
- public void setShowLabel(boolean var1) {
- this.showLabel = var1;
- }
-
- public boolean getShowLabel() {
- return this.showLabel;
- }
-
- public void paint(Graphics var1) {
- if (super.showFocus) {
- Dimension var2 = ((Component)this).size();
- Rectangle var3 = ((Component)this).bounds();
- Color var4 = var1.getColor();
- if (this.color1 != null) {
- this.yTemp = 1 + this.indent;
- } else {
- this.yTemp = 1;
- }
-
- this.field_0 = ((Component)this).getFontMetrics(((Component)this).getFont());
- this.yTemp = (var3.height - this.yTemp + this.field_0.getAscent()) / 2;
- switch (this.alignStyle) {
- case 0:
- if (this.bevelStyle == 2) {
- this.xTemp = 4;
- } else {
- this.xTemp = 8;
- }
- break;
- case 1:
- this.xTemp = (var3.width - this.field_0.stringWidth(this.sLabelButton)) / 2;
- break;
- case 2:
- this.xTemp = var3.width - this.field_0.stringWidth(this.sLabelButton);
- if (this.bevelStyle == 2) {
- this.xTemp -= 6;
- } else {
- this.xTemp -= 10;
- }
- }
-
- if ((!super.inButton || !super.showFocus) && !this.showLabel) {
- if (!super.inButton && super.showFocus) {
- var1.setColor(((Component)this).getBackground());
- var1.drawRect(0, 0, var2.width - 1, var2.height - 1);
- var1.fillRect(this.xTemp, this.yTemp - this.field_0.getAscent(), this.field_0.stringWidth(this.sLabelButton), this.field_0.getAscent());
- }
- } else {
- var1.setColor(super.inButton ? Color.gray : ((Component)this).getBackground());
- var1.drawRect(0, 0, var2.width - 1, var2.height - 1);
- var1.setColor(this.textColor);
- var1.drawString(this.sLabelButton, this.xTemp, this.yTemp);
- }
-
- if (super.doInfoTip) {
- ((ButtonBase)this).drawInfoTip();
- }
-
- }
- }
-
- public Dimension preferredSize() {
- Dimension var1 = ((Component)this).size();
- Dimension var2 = this.minimumSize();
- return new Dimension(Math.max(var1.width, var2.width), Math.max(var1.height, var2.height));
- }
-
- public Dimension minimumSize() {
- Dimension var1 = new Dimension(18, 10);
- Font var2 = ((Component)this).getFont();
- if (var2 == null) {
- if (this.bOsFlag) {
- var1.height = 29;
- }
- } else {
- this.field_0 = ((Component)this).getFontMetrics(var2);
- var1.width = this.field_0.stringWidth(this.sLabelButton) + 18;
- var1.height = this.field_0.getHeight() + 10;
- if (this.bOsFlag && var1.height < 29) {
- var1.height = 29;
- }
- }
-
- return var1;
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- if (!((Component)this).isValid()) {
- ((Component)this).repaint();
- }
-
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
- }
-